<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>维修记录</title>
    <meta name="keywords" content="设置关键词..."/>
    <meta name="description" content="设置描述..."/>
    <meta name="author" content="DeathGhost"/>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <link rel="icon" href="images/icon/favicon.ico" type="image/x-icon">
    <link rel="stylesheet" type="text/css" href="css/style.css"/>
    <link rel="stylesheet" type="text/css" href="BootStrap/css/bootstrap.css">

    <script src="BootStrap/js/jquery.js"></script>
    <script src="BootStrap/js/bootstrap.js"></script>
</head>
<body>
<div class="page-wrap">
    <section class="page-hd">
        <header>
            <h2 class="title">维修记录</h2>
        </header>
        <hr>
    </section>
    <div class="breadcrumb">
        <ul>
            <li><a>售后管理</a><i class="icon-angle-right"></i></li>
            <li><a href="Report.html">维修记录</a><i class="icon-angle-right"></i></li>
        </ul>
    </div>

</div>

<div class="page-wrap">

    <form id="myform" class="form-inline">
        <br>
        <div>
            <i class="icon-search"></i>
            <input type="text" class="form-control" placeholder="请输入维修ID" id="reportId" style="width:350px"
                   name="reportId">
            <br>
        </div>
        <div id="TheReport">

        </div>
        <div>
            维修状态:
            <select class="form-control" name="reportStatus">
                <option value="">--全部状态--</option>
                <option value="1">待修复</option>
                <option value="2">修复中</option>
                <option value="3">已修复</option>
                <option value="4">无法修复</option>
            </select>
            <br>
        </div>
        <div>

            <button type="button" class="btn btn-primary" name="Se">搜索</button>

            <br>
            <br>
        </div>
    </form>
</div>

<div class="breadcrumb">
    <table class="table table-striped table-bordered table-hover" style="width: 100%;margin: 20px auto">
        <thead>
        <tr class='cen'>
            <th><input type="checkbox"/></th>
            <th>维修ID</th>
            <th>故障ID</th>
            <th>故障类型</th>
            <th>维修说明</th>
            <th>维修人</th>
            <th>维修状态</th>
            <th>维修时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody id="tbody">

        </tbody>
    </table>
    <ul class="pagination pull-right" id="page">

    </ul>
</div>

<!--删除模态框开始-->
<div class="modal fade" id="delReport_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <h1 style="text-align: center">你确认要删除吗？</h1>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="delReport">删除</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!--删除模态框结束-->
<script>
    request(1);

    function request(pageNum) {
        var reportId = $("[name=reportId]").val();
        var userName = $("[name=userName]").val();
        var reportStatus = $("[name=reportStatus]").val();

        $.ajax({
            url: '/report/list',
            type: 'post',
            datatype: 'json',
            data: {
                "reportId": reportId,
                "userId": userName,
                "reportStatus": reportStatus,

                "pageNum": pageNum
            },
            success: function (data) {
                show(data);
            }
        })
    }

    function show(data) {
        var str = "";
        for (var i in data.page.list) {
            var a = data.page.list[i];
            str += "<tr>";
            str += "<td><input type='checkbox'/></td>";
            str += "<td>" + a.reportid + "</td>";
            str += "<td>" + a.sesUserFeedback.userfeedbackid + "</td>";
            if (a.sesUserFeedback.userfeedbacktype==0){
                str+="<td>其他损坏</td>"
            }else if (a.sesUserFeedback.userfeedbacktype==1){
                str+="<td>床位损坏</td>"
            }else if (a.sesUserFeedback.userfeedbacktype==2){
                str+="<td>柜门损坏</td>"
            }else if (a.sesUserFeedback.userfeedbacktype==3){
                str+="<td>无法归还</td>"
            }

            str += "<td>" + a.sesUserFeedback.userfeedbackcontent + "</td>";
            str += "<td>" + a.sesUser.username + "</td>";
            if (a.reportstatus==1){
                str+="<td>待修复</td>"
            }else if (a.reportstatus==2){
                str+="<td>修复中</td>"
            }else if (a.reportstatus==3){
                str+="<td>已修复</td>"
            }else if (a.reportstatus==2){
                str+="<td>无法修复</td>"
            }
            str += "<td>" + a.reporttime + "</td>";
            str += "<td>";
            str += "<input type='hidden' name='reportId' value='" + a.reportid + "'>";
            str += "<a title='详情' class='mr-5'>详情</a>";
            str += "<a name='del' onclick='del()'> 删除</a>";
            str += "</td></tr>";
        }
        $("#tbody").html(str);

        var page = "";
        page += '<li class="' + (data.page.pageNum == 1 ? 'disabled' : '') + '"><a onclick="getAll(' + data.page.prePage + ')" >上一页</a></li>';
        for (var i = 1; i <= data.page.pages; i++) {
            page += ' <li class="' + (data.page.pageNum == i ? 'active' : '') + '"><a onclick="getAll(' + i + ')">' + i + '<span class="sr-only"></span></a></li>';
        }
        page += ' <li ><a onclick="getAll(' + data.page.nextPage + ')" >下一页</a></li>';
        $("#page").html(page);

        var reporter = "";
        reporter += "维修人员：";
        reporter += " <select class='form-control' name='userName'>";
        reporter += "<option value=''>--所有维修人员--</option>"
        for (var i in data.weixiu) {
            var w = data.weixiu[i];
            reporter += "<option value='" + w.userid + "'>" + w.username + "</option>";
        }
        reporter += "</select>"
        $("#TheReport").html(reporter);
    }


    //删除弹出模态框

    function del() {
        $("[name=del]").click(function () {
            $("#delReport_modal").modal("show");
        })

    }

    //确认删除删除模态框
    delReport();

    function delReport() {
        var reportId = $("[name=reportId]").val();

        $("#delReport").click(function () {
            $.ajax({
                type: 'post',
                url: '/report/delete',
                data: {"reportId": reportId},
                success: function (data) {
                    $("#delReport_modal").modal("hide");
                    request(1);
                }
            });
        })
    }

    se();

    function se() {
        $(":button[name=Se]").click(function () {
            request(1);
        });

    }



</script>
</body>
</html>